
<template>
  <rm-layout-top splitcolor="white" :splitwidth=5 :fixsize=35 :canDrag=false>
      <template v-slot:fix>
          <div style="height:35px;border:1px solid #CCC;padding:4px">
              <table style="padding-top:0px;border-spacing:0px">
                  <tr>
                      <td style="width:800px">
                          <div class="grid-content bg-purple"> <span class="remind_class">近7日内以下项目用血计价失败，请予以关注！</span></div>
                      </td>
                      <td style="width:70px">
                          <el-button style="width:60px" @click.native="btnRehandle">重新处理</el-button>
                      </td>
                      <td style="width:70px">
                          <el-button style="width:60px" @click.native="btnstop">停止处理</el-button>
                      </td>
                      <td style="width:70px">
                          <el-button style="width:60px" @click.native="btnClose">退出</el-button>
                      </td>
                  </tr>
              </table>

          </div>
      </template>
      <div style="height:100%">
          <vxe-table show-overflow ref="xTable" :data.sync="BldChargeAlertData" width="100%" height="100%" border size="mini" :select-config="{ reserve: true }" highlight-current-row show-header-overflow resizable header-align="center" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" key="1" :cell-class-name="cellclassname" class="mytable-style" @current-change="currentChangeEvent" :loading="loading" @select-change="selectChangeEvent">
              <vxe-table-column type="selection" width="40" header-align="center" align="center"> </vxe-table-column>
              <vxe-table-column field="chargedt" title="生成时间" width="120" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']" align="center"></vxe-table-column>
              <vxe-table-column field="pat_no" :title="Getcolname('pat_no','病历号')"  width="80"></vxe-table-column>
              <vxe-table-column field="pat_name" title="姓名" width="60"></vxe-table-column>
              <vxe-table-column field="pat_wardnoname" title="病区" width="100"></vxe-table-column>
              <vxe-table-column field="pat_bedno" title="床号" width="70" align="center"></vxe-table-column>
              <vxe-table-column field="orderno" title="申请单号" width="100"></vxe-table-column>
              <vxe-table-column field="req_itemname" title="收费项目" width="150"></vxe-table-column>
              <vxe-table-column field="exec_comment" title="计价相关信息或失败相关信息" width="300"></vxe-table-column>
              <vxe-table-column field="his_code" title="接口代码" width="60"></vxe-table-column>
              <vxe-table-column field="exec_failcnt" title="失败次数" width="50" align="center"></vxe-table-column>
              <vxe-table-column field="comments" title="备注说明" width="200"></vxe-table-column>
              <vxe-table-column field="item_price" title="基础价格" width="60" align="right" header-align="center"></vxe-table-column>
              <vxe-table-column field="amounts" title="金额" width="70" align="right" header-align="center"></vxe-table-column>
              <vxe-table-column field="pat_deptnoname" title="申请科室" width="100"></vxe-table-column>
              <!--vxe-table-column field="perform_deptname" title="执行科室" width="100"></vxe-table-column-->
              <vxe-table-column field="orderid" title="申请ID" width="120"></vxe-table-column>

              <template v-slot:fix>
                  <div style="font-size:17px;padding-top:3px;background-color:#fff;text-align:center;font-weight:bold;color:blue">共 {{datacnt}} 条</div>
              </template>
          </vxe-table>
      </div>
  </rm-layout-top>

</template>

<script type="text/javascript">
export default {
  name: "rm_bldchargealert",
  props: {
      tabledata: { type: Array },
      params: { type: Object },
      coldate:{type:Array,default:[]},
  },
  data() {
      return {
          BldChargeAlertData: this.tabledata,
          loading: false,
          remindobj: { barcodes: "", confirmusername: "", chkremind: "0", isfirstconfirm: false }
      };
  },
  created() {
      // console.log("2221", this.params);
  },
  computed: {
      datacnt() {
          return this.BldChargeAlertData.length;
      }
  },
  watch: {},
  mounted() {
      this.setcurRow(this.BldChargeAlertData);
  },
  methods: {
      //获取自动提醒弹窗的选中行
      currentChangeEvent({ row, column }) {
          // this.remindobj.selrow = row;
      },
      //不再提醒，记录下点击时的时间，该时间之前的不再显示
      chkremindChange() {
          if (this.remindobj.chkremind == "1") {
              // this.$ddldata.msgparm.localReqChargedt = this.$pub.InitDateTime();
          } else {
              // this.$ddldata.msgparm.localReqChargedt = "";
          }
      },
      //自动提醒弹窗列表的颜色
      cellclassname({ row, column }) {
          if (column.property == "orderno") {
              return "col-blue";
          } else if (column.property == "chargefailmsg") {
              return "col-red";
          }
      },
      btnstop() {
          let selrow = this.$refs.xTable.getSelectRecords();
          var savelist = [];
          for (var _row of selrow) {
              let _orderid = _row.orderid;
              if (!savelist.includes(_orderid)) {
                  savelist.push(_orderid);
              }
          }
          console.log(savelist);
          this.$tool
              .request({
                  url: "ucent/bldalert",
                  method: "post",
                  data: {
                      action: "stopcharge",
                      orderlist: savelist
                  }
              })
              .then(res => {
                  if (res.retcode != "1") {
                      this.$alert("执行错误:" + res.errmsg, "提示");
                  } else {
                      this.$refs.xTable.removeSelecteds();
                      this.$emit("change", "bldcharge", this.params);
                  }
                  ///
              })
              .catch(e => {
                  this.$alert(e, "出错");
              });
      },
      Getcolname(colcode,colname)
      {
          if (this.coldate.length <=0) return colname;
          let  _Set =  this.coldate.find(m=> m.col_code == colcode);
          if (_Set)
          {
              return   _Set.col_label;
          }
          return  colname;
      },
      //重新处理(更新失败次数为0)
      btnRehandle() {
          let selrow = this.$refs.xTable.getSelectRecords();
          var savelist = [];
          for (var _row of selrow) {
              let _orderid = _row.orderid;
              if (!savelist.includes(_orderid)) {
                  savelist.push(_orderid);
              }
          }
          console.log(savelist);
          this.$tool
              .request({
                  url: "ucent/bldalert",
                  method: "post",
                  data: {
                      action: "recharge",
                      orderlist: savelist
                  }
              })
              .then(res => {
                  if (res.retcode != "1") {
                      this.$alert("执行错误:" + res.errmsg, "提示");
                  } else {
                      this.$refs.xTable.removeSelecteds();
                      this.$emit("change", "bldcharge", this.params);
                  }
                  ///
              })
              .catch(e => {
                  this.$alert(e, "出错");
              });
      },
      selectChangeEvent({ checked, row }) {
          let _orderid = row.orderid;
          //xTable" :data.sync="BldChargeAlertData
          let _selected = this.BldChargeAlertData.filter(item => item.orderid == _orderid);

          for (var _row of _selected) {
              this.$refs.xTable.setSelection(_row, checked);
          }

          //this.$refs.maintable.setSelection(_bldlist[0], true);
      },
      //刷新仪器危急值
      btnRefresh() {
          /*  this.loading = true;
          this.$tool
              .request({
                  url: "ucent/alertmsg",
                  method: "post",
                  data: {
                      params: this.params.paramlist
                  }
              })
              .then(res => {
                  this.ReqChargeAlertData = res.data;
                  if (this.$refs.xTable && res.data.length > 0) this.setcurRow(res.data[0]);
                  this.loading = false;
              })
              .catch(e => {
                  this.$alert(e, "提示");
                  this.loading = false;
              });*/
      },
      setcurRow(data) {
          if (this.$refs.xTable && data.length > 0) {
              this.$refs.xTable.setCurrentRow(data[0]);
          }
      },
      //退出
      btnClose() {
          this.$emit("change", "bldcharge", this.params);
      }
  }
};
</Script>

<style scoped>
.remind_class {
  color: rgb(236, 11, 11);
  font-size: 18px;
}
::v-deep .mytable-style .vxe-body--row.row-pink {
  background-color: pink;
  color: rgb(8, 8, 8);
}

::v-deep  .mytable-style .vxe-body--column.col-red {
  background-color: red;
  color: #fff;
}
::v-deep  .mytable-style .vxe-body--column.col-blue {
  background-color: #2db7f5;
  color: #fff;
}
::v-deep .el-checkbox__inner::after {
  border: 2px solid #000000 !important;
  box-sizing: content-box;
  content: "";
  border-left: 0 !important;
  border-top: 0 !important;
  height: 7px;
  left: 4px;
  position: absolute;
  top: 1px;
  transform: rotate(45deg) scaleY(0);
  width: 3px;
  transition: transform 0.15s ease-in 0.05s;
  transform-origin: center;
}
::v-deep .el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #000000;
  cursor: not-allowed;
}
</style>